package cn.community.care.module.system.dal.mysql.illnesshistory;

import java.util.*;

import cn.community.care.framework.common.pojo.PageResult;
import cn.community.care.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.community.care.framework.mybatis.core.mapper.BaseMapperX;
import cn.community.care.module.system.controller.admin.illnesshistory.vo.IllnessHistoryPageReqVO;
import cn.community.care.module.system.dal.dataobject.illnesshistory.IllnessHistoryDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户生病历史 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface IllnessHistoryMapper extends BaseMapperX<IllnessHistoryDO> {

    default PageResult<IllnessHistoryDO> selectPage(IllnessHistoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IllnessHistoryDO>()
                .eqIfPresent(IllnessHistoryDO::getUserId, reqVO.getUserId())
                .likeIfPresent(IllnessHistoryDO::getDiseaseName, reqVO.getDiseaseName())
                .eqIfPresent(IllnessHistoryDO::getTreatmentSituation, reqVO.getTreatmentSituation())
                .eqIfPresent(IllnessHistoryDO::getAllergyHistory, reqVO.getAllergyHistory())
                .eqIfPresent(IllnessHistoryDO::getSurgeryHistory, reqVO.getSurgeryHistory())
                .eqIfPresent(IllnessHistoryDO::getGeneticDiseaseHistory, reqVO.getGeneticDiseaseHistory())
                .betweenIfPresent(IllnessHistoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IllnessHistoryDO::getId));
    }

}